package top.laoshuzi.rpi3

import lib.bcm2835.*

enum class Pwm {

    INSTANCE;

    private var bcm2835Manager: Bcm2835Manager = Bcm2835Manager.INSTANCE

    init {
        bcm2835_gpio_fsel(RPI_BPLUS_GPIO_J8_12.toUByte(), BCM2835_GPIO_FSEL_ALT5.toUByte())
        bcm2835_pwm_set_clock(192U)
        bcm2835_pwm_set_mode(0, 1, 1)
    }

    fun setData(data: UInt) {
        bcm2835_pwm_set_data(0, data)
    }

    fun setData(range: UInt, data: UInt) {
        bcm2835_pwm_set_range(0, range)
        bcm2835_pwm_set_data(0, data)
    }


}